//////////////////////////////////////////////////////////////////////////////////////////////////
//	File: AnimationManager.h
//
//	Author: Justin Maza
//
//	Purpose: Manages the animations of all game objects. Uses a string as an index into its
//			 map of animations
//////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once

#include <map>
#include "Animation.h"
#include "tinyxml\tinyxml.h"
#include <iostream>
#include <vector>

using namespace std;

class BaseCharacter;

class AnimationManager
{
private:
	//map<int,Animation*> m_Animations;						// List of animations that are indexed by integer input
	vector<Animation*> v_Animations;
	static AnimationManager* pInstance;						// Pointer to the Manager
	CSGD_TextureManager* pTM;
	int currentRect;
	int numElements;
	double anchorX, anchorY;
	int left, top, right, bottom;
	RECT* frameArray;
	POINT* ptPointArray; 
	float* DurArray;
	DWORD color;
	string* triggerName;
	int* triggerType;

	//	SINGLETON!
	AnimationManager(void);
	AnimationManager(const AnimationManager&);
	~AnimationManager(void);
	AnimationManager& operator=(const AnimationManager&);


public:
	
	static AnimationManager* GetInstance(void);												// Returns the static pointer to the Manager
	static void DeleteInstance(void);														// Deletes the pointer to the Manager.  ***Only is called when the game window closes!***

	void Render(BaseCharacter* pCharacter);													// Renders animations depending on what the Character's current animation is.
	void Render(BaseCharacter* pCharacter, int posX, int posY, float fScale, bool isFlip);	// Renders animations depending on what the Character's current animation is.  Overloaded to take in an X and Y position.
	void Update(BaseCharacter* pCharacter, float elapsedTime);								// Updates animations depending on what the Character's current animation is.

	void AddAnimation(Animation* pAnimation);												// Adds the passed in Animation (if it exists) to the Manager's map
	void RemoveAnimation(Animation* pAnimation);											// Removes the passed in Animation (if it exists) from the Manager's map
	void RemoveAllAnimations(void);															// Clears the map.
	void ShutdownAnimationManager(void);													// Clears the map and delete's the Manager's instance.  ***Only call when the game window closes!***

	bool LoadAnimations(const char* filePath);
	void SaveAnimations(const char* filePath, vector<Animation*>& vAnimations);

};

